chrome.storage.sync.get({username: ''}, function (items) {
  let username = document.getElementById('username')
  let user = document.getElementById('user')
  let login = document.getElementById('login')
  if (items.username) {
    username.innerText = items.username
    user.style.display = 'block'
    login.style.display = 'none'
  } else {
    user.style.display = 'none'
    login.style.display = 'block'
  }
})
function sendMessageToContentScript(message, callback) {
  chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
    chrome.tabs.sendMessage(tabs[0].id, message, function (response) {
      callback && callback(response);
    });
  });
}

document.getElementById('login').addEventListener("click", function () {
  sendMessageToContentScript({cmd: 'open', value: ''});
})
